{
  LX Action module

  Based on modo's SDK lxaction.h which is:

  Copyright (c) 2008-2012 Luxology LLC

  Permission is hereby granted, free of charge, to any person obtaining a
  copy of this software and associated documentation files (the "Software"),
  to deal in the Software without restriction, including without limitation
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
  and/or sell copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.   Except as contained
  in this notice, the name(s) of the above copyright holders shall not be
  used in advertising or otherwise to promote the sale, use or other dealings
  in this Software without prior written authorization.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.
}

{
  Copyright (c) 2012 David Ballesteros and Jameel Halabi

  This unit is part of the BLAISEmodo wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit Lx_Action;

{$mode objfpc}{$H+}

interface

uses
  Lx_Result;

const
  LXa_EVALMODIFIER       = 'evalModifier';

  LXeEVAL_DIFFERENT      = LXe_OK;

  LXfECHAN_READ          = $01;
  LXfECHAN_WRITE         = $02;
  LXfECHAN_SETUP         = $04;

  LXs_ACTIONLAYER_SETUP  = 'setup';
  LXs_ACTIONLAYER_ANIM   = 'scene';
  LXs_ACTIONLAYER_EDIT   = 'edit' ;

  LXsMOD_TYPELIST        = 'modifier.typeList' ;
  LXsMOD_GRAPHLIST       = 'modifier.graphList';
  LXsMOD_GUIDLIST        = 'modifier.guidList' ;
  LXsMOD_REQUIREDTYPE    = 'modifier.required' ;

  LXu_ACTIONLISTENER     = '{4819A297-A922-11D8-B1AD-000393CE9680}';
  LXu_CHANNELREAD        = '{D5A8C4FD-151C-4D8B-97E1-6E1B4087886B}';
  LXu_CHANNELWRITE       = '{91BFE3B8-16C6-4195-BFE5-3F0E3C0C5C57}';
  LXu_EVALUATION         = '{FB552E5F-746E-4d74-885C-40A931B82B84}';
  LXu_EVALMODIFIER       = '{30AAAF24-9699-4737-8E3B-E264AA4B7A3E}';
  LXu_MODIFIER           = '{8D3BEC86-E10B-426A-8BA3-846250E25AF4}';
  LXu_MODIFIER1          = '{FA406E1C-5E6A-4574-A795-AA0F07DFAFB5}';
  LXu_SIMULATIONMODIFIER = '{A44F37F3-E94F-4042-85E2-1BBF633E00D2}';

type
  ILxActionListener = interface
  [LXu_ACTIONLISTENER]
    procedure ActionChannelSignal           (Item    : IUnknown;
                                             Channel : UInt32  ) ;
    procedure ActionChannelConstantChange   (Item    : IUnknown;
                                             Channel : UInt32  ) ;
    procedure ActionChannelConstantPreChange(Item    : IUnknown;
                                             Channel : UInt32  ) ;
  end;

  ILxChannelRead = interface
  [LXu_CHANNELREAD]
    function ValueObj    (    Item        : IUnknown;
                              Channel     : UInt32  ;
                          out VObj                  ) : LxResult;
    function Integer     (    Item        : IUnknown;
                              Channel     : UInt32  ;
                              Value       : PInteger) : LxResult;
    function Double      (    Item        : IUnknown;
                              Channel     : UInt32  ;
                              Value       : PDouble ) : LxResult;
    function &String     (    Item        : IUnknown;
                              Channel     : UInt32  ;
                              Value       : PPChar  ) : LxResult;
    function Envelope    (    Item        : IUnknown;
                              Channel     : UInt32  ;
                          out VObj                  ) : LxResult;
    function Time                                     : Double  ;
    function IsAnimated  (    Item        : IUnknown;
                              Index       : Integer ) : Integer ; // Result type changed in SDK 52162
    function IsBaked     (    Item        : IUnknown;
                              Channel     : UInt32  ) : LxResult;
    function BakedSamples(    Item        : IUnknown;
                              Channel     : UInt32  ;
                              FirstSample : PDouble ;
                              SPSRate     : PDouble ;
                          out VObj                  ) : LxResult;
  end;

  ILxChannelWrite = interface
  [LXu_CHANNELWRITE]
    function ValueObj   (      Item        : IUnknown;
                               Channel     : UInt32  ;
                           out VObj                  ) : LxResult;
    function Integer    (      Item        : IUnknown;
                               Channel     : UInt32  ;
                               Value       : Integer ) : LxResult;
    function Double     (      Item        : IUnknown;
                               Channel     : UInt32  ;
                               Value       : Double  ) : LxResult;
    function &String    (      Item        : IUnknown;
                               Channel     : UInt32  ;
                         const Value       : PChar   ) : LxResult;
    function Envelope   (      Item        : IUnknown;
                               Channel     : UInt32  ;
                           out VObj                  ) : LxResult;
    function IntegerKey (      Item        : IUnknown;
                               Channel     : UInt32  ;
                               Value       : Integer ;
                               Create      : Integer ) : LxResult;
    function DoubleKey  (      Item        : IUnknown;
                               Channel     : UInt32  ;
                               Value       : Double  ;
                               Create      : Integer ) : LxResult;
    function SetState   (      Item        : IUnknown;
                               Channel     : UInt32  ;
                               State       : UInt32  ) : LxResult;
    function BakeSamples(      Item        : IUnknown;
                               Channel     : UInt32  ;
                               FirstSample : Double  ;
                               SPSRate     : Double  ;
                           out VObj                  ) : LxResult;
  end;

  ILxEvalModifier = interface
  [LXu_EVALMODIFIER]
    function Reset (    Scene : IUnknown) : LxResult;
    function Next  (    Index : PUInt32 ) : IUnknown;
    function Alloc (    Item  : IUnknown;
                        Index : UInt32  ;
                        Eval  : IUnknown;
                    out VObj            ) : LxResult;
  end;

  ILxModifier = interface
  [LXu_MODIFIER]
    function  Evaluate                            : LxResult;
    function  Test         (    Item  : IUnknown;
                                Index : UInt32  ) : LxResult;
    function  Invalidate   (    Item  : IUnknown;
                                Index : UInt32  ) : LxResult;
    function  Validate     (    Item  : IUnknown;
                                Index : UInt32  ;
                                RC    : LxResult) : LxResult;
    function  RequiredCount                       : UInt32  ;
    function  Required     (    Index : UInt32  ;
                                Attr  : PUInt32 ;
                            out VObj            ) : LxResult;
    procedure Free         (    Cache : Pointer ) ;
  end;

  ILxSimulationModifier = interface
  [LXu_SIMULATIONMODIFIER]
    function  Initialize(Time     : Double ;
                         Sample   : Double ) : LxResult;
    procedure Cleanup                        ;
    function  StepSize  (StepSize : PDouble) : LxResult;
    function  Step      (DT       : Double ) : LxResult;
  end;

  ILxEvaluation = interface
  [LXu_EVALUATION]
    function AddChannel       (      Item     : IUnknown;
                                     Index    : UInt32  ;
                                     &Type    : UInt32  ;
                                     Attr     : PUInt32 ) : LxResult;
    function AddChannelName   (      Item     : IUnknown;
                               const Name     : PChar   ;
                                     &Type    : UInt32  ;
                                     Attr     : PUInt32 ) : LxResult;
    function ReadTime         (      Attr     : PUInt32 ) : LxResult;
    function SetAlternateTime (      Time     : Double  ) : LxResult;
    function SetAlternate     (  out VObj               ) : LxResult;
    function ClearAlternate                               : LxResult;
    function SetCache         (      Cache    : Pointer ) : LxResult;
    function GetCache                                     : Pointer ;
    function SetAlternateSetup                            : LxResult;
    function GetBakedSample   (      Index    : UInt32  ;
                                     Bracket  : UInt32  ;
                                     Fraction : PDouble ;
                                 out VObj               ) : LxResult;
  end;

  ILxModifier1 = interface
  [LXu_MODIFIER1]
    function  Evaluate                            : LxResult;
    function  Test         (    Item  : IUnknown;
                                Index : UInt32  ) : LxResult;
    function  Invalidate   (    Item  : IUnknown;
                                Index : UInt32  ) : LxResult;
    function  RequiredCount                       : UInt32  ;
    function  Required     (    Index : UInt32  ;
                                Attr  : PUInt32 ;
                            out VObj            ) : LxResult;
    procedure Free         (    Cache : Pointer ) ;
  end;

function LXeEVAL_IDENTICAL : LxResult;

implementation

function LXeEVAL_IDENTICAL : LxResult; inline;
begin
  Result := LXxGOODCODE(LXeSYS_EVAL, 1);
end;

end.

